﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BTN04.DAO;
using BTN04.DTO;
using System.Collections.Generic;

namespace BTN04.BUS
{
    public class SanPhamBUS
    {
         public List<SanPhamDTO> DanhSachSanPhamTheoLoai(int _maLoai)
        {
            SanPhamDAO spDao = new SanPhamDAO();
            return spDao.DanhSachSanPhamTheoLoai(_maLoai);
        }

         public List<SanPhamDTO> SanPhamXemNhieuTrongNgay()
        {
            SanPhamDAO spDao = new SanPhamDAO();
            return spDao.SanPhamXemNhieuTrongNgay();
        }
        public List<SanPhamDTO> SanPhamNew()
        {
            SanPhamDAO spDao = new SanPhamDAO();
            return spDao.SanPhamNew();
        }
         public DataTable LaySanPhamTheoMa(string _maSanPham)
        {
            SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.LaySanPhamTheoMa(_maSanPham);
        }
         public List<SanPhamDTO> DanhSachSanPhamCungLoai(int _maLoai)
        {
            SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.DanhSachSanPhamCungLoai(_maLoai);
        }
         public DataTable TimKiemThuong(SanPhamCrt spCrt)
         {
             SanPhamDAO spDAO = new SanPhamDAO();
             return spDAO.TimKiemThuong(spCrt );
         }
        public DataTable TimKiemNangCao(string TenSanPham,int GiaTu,int GiaDen,int MaNhaSanXuat,int MaLoaiSanPham,int MaXuatSu)
        {
            SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.TimKiemNangCao(TenSanPham, GiaTu, GiaDen, MaNhaSanXuat, MaLoaiSanPham, MaXuatSu);
        }
         public int SoLuongSanPham()
        {
            SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.SoLuongSanPham();
        }
        public List<SanPhamDTO> StoreToDataSet(int currPage, int recodperpage, int Pagesize)
        {
            SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.StoreToDataSet(currPage, recodperpage, Pagesize);
        }

        public static SanPhamDTO LaySanPhamTheoMa(int masp)
        {
            return SanPhamDAO.LaySanPhamTheoMa(masp);
        }

         public DataTable SanPhamTop10SoLuongBan()
        {
            SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.SanPhamTop10SoLuongBan();
        }
         public DataTable SanPhamTop10SoLuongBanTheoLoaiSanPham(int MaLoaiSanPham)
        {
            SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.SanPhamTop10SoLuongBanTheoLoaiSanPham(MaLoaiSanPham);
        }

         //Xoa 1 san pham dua vao ma
         public int XoaMotSanPhamDuaVaoMa(int ma)
         {

             SanPhamDAO spDAO = new SanPhamDAO();
             return spDAO.XoaMotSanPhamDuaVaoMa(ma);

         }

        //ham update lai so luong ton
        public int CapNhatSoLuongTon(int masp, int soluong)
        {
            SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.CapNhatSoLuongTon(masp ,soluong );
        }

        public List<SanPhamDTO> HienThiChiTietToanBoSanPham()
        {
            SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.HienThiChiTietToanBoSanPham();
        }
        //Hien thi chi chi tiet 1 san pham theo Ma San Pham
        public SanPhamDTO HienThiChiTietSanPhamTheoMa(int ma)
        {
           SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.HienThiChiTietSanPhamTheoMa (ma);
        }
        
        //Cap nhat thong tin 1 san Pham
        public int CapNhatMotSanPham(SanPhamDTO spDto)
        {

            SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.CapNhatMotSanPham(spDto );

        }

        //Thêm 1 san pham
        public int ThemMotSanPham(SanPhamDTO spDto)
        {

            SanPhamDAO spDAO = new SanPhamDAO();
            return spDAO.ThemMotSanPham(spDto );
        }

    }
}
